9. The Unix Philosophy
Unix's Legacy Today
Information technology has changed and evolved at an incredible pace. But Unix has been around for more than five decades, and its philosophy, API design, and tools still live on in Unix and Unix-like operating systems.

"When do I get to retire?"
Unix's legacy is still all around us. Android and Linux distributions such as Debian, Ubuntu, and Arch Linux use the Linux kernel. Apple's macOS and iOS, which run on Macs and iPhones, are Unix-based too. Even Windows can run a Linux environment through the Windows Subsystem for Linux (WSL).
%%{init: {"look": "handDrawn", "theme": "neutral"}}%%
flowchart TB
Unix([Unix]) --> BSD([BSD])
Unix --> SystemV([System V])
BSD --> NeXTSTEP([NeXTSTEP])
BSD --> FreeBSD([FreeBSD])
BSD --> SunOS([SunOS])
SunOS --> Solaris([Solaris])
SystemV -- SVR4 base --> Solaris
Solaris --> OpenSolaris([OpenSolaris])
NeXTSTEP --> MacOSX([Mac OS X])
MacOSX --> macOS([macOS])
MacOSX --> iOS([iOS])
MINIX([MINIX]) -. influenced development .-> Linux([Linux])
Linux -. runs on Windows through .-> WSL([WSL])MINIX was developed as a small Unix-like system for teaching operating system design. For a more detailed family tree, see Wikipedia.
From MINIX to Linux
In 1979, the Unix V7 license prohibited using its source code in the classroom. In response, Professor Tanenbaum developed MINIX to teach operating system design and released it in 1987.

"Maybe I should build a simple OS for my students."
In 1991, Linus Torvalds was using MINIX on his newly purchased Intel 386 PC. While reading Tanenbaum's Operating Systems: Design and Implementation, he began developing the Linux kernel.

"Long winter break... I think I'll read this MINIX book."
The Linux kernel did not use MINIX or Unix source code. It implemented POSIX-style standard interfaces so that source code for existing Unix programs could be compiled and run without modification, and the Linux 0.01 release already came with a port of the Bash shell[5].

"I started implementing the system calls I needed to get Bash running."
What Is the Unix Philosophy?

"How has Unix continued to shape the tech world for so long?"
To find the answer, we need to understand the Unix philosophy. But Unix did not start with a grand philosophy. Eric S. Raymond later summed it up with a familiar design principle:

"Keep it simple, stupid."[1]

"Come on, you must be joking. Tell me the real philosophy."

"Hmm... We just made it."
According to Wikipedia, "The Unix philosophy, originated by Ken Thompson, is a set of cultural norms and philosophical approaches to minimalist, modular software development. It is based on the experience of leading developers of the Unix operating system."[2]

"Think of small, modular programs. The philosophy grew out of the early Unix developers' experience."

"I still don't really get it."
Programs That Do One Thing Well
In 1978, Doug McIlroy formally documented the philosophy:[3]
- Make each program do one thing well. To do a new job, build afresh rather than complicate old programs by adding new features.
- Expect the output of every program to become the input to another, as yet unknown, program. Do not clutter output with extraneous information. Avoid stringently columnar or binary input formats. Do not insist on interactive input.
- Design and build software, even operating systems, to be tried early, ideally within weeks. Do not hesitate to throw away the clumsy parts and rebuild them.
- Use tools in preference to unskilled help to lighten a programming task, even if you have to detour to build the tools and expect to throw some of them out after you have finished using them.

"That's too long. Make it simpler!"
Peter H. Salus later summarized the philosophy once more:[4]
- Write programs that do one thing and do it well.
- Write programs to work together.
- Write programs to handle text streams, because that is a universal interface.

"Just like building with LEGO bricks!"
C and Unix Portability
Like LEGO bricks, Unix programs can be connected through their inputs and outputs to build more complex tools. Unix was later rewritten largely in C, making it much easier to port to different computers.
A compiler translates C source code into machine code for its target processor. Of course, hardware-specific code and low-level assembly routines still need to be adapted for each platform.


"Back then, kernels were usually written in assembly. Developing C and using it to rewrite an OS kernel—that was quite an idea!"

"Unix influenced many operating systems for more than just technical reasons. Its source code had a way of traveling. But that's a story for another time..."
"Where are you going?"

"That's a secret." (Unix source code on magnetic tape.)
References
- Eric S. Raymond, "The Unix Philosophy in One Lesson", The Art of Unix Programming, Addison-Wesley, 2003.
- "Unix philosophy", Wikipedia.
- M. D. McIlroy, E. N. Pinson, and B. A. Tague, "Unix Time-Sharing System: Foreword", Bell System Technical Journal 57, no. 6, 1978, pp. 1899–1904.
- Peter H. Salus, A Quarter Century of UNIX, Addison-Wesley, 1994, pp. 52–53.
- Linus Torvalds, Notes for Linux release 0.01, 1991.